<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>perlvms - VMS-specific documentation for Perl - Perldoc Browser</title>
    <link rel="search" href="https://perldoc.perl.org/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser">
    <link rel="canonical" href="https://perldoc.perl.org/perlvms">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/stackoverflow-light.min.css" integrity="sha512-cG1IdFxqipi3gqLmksLtuk13C+hBa57a6zpWxMeoY3Q9O6ooFxq50DayCdm0QrDgZjMUn23z/0PMZlgft7Yp5Q==" crossorigin="anonymous" />
    <style>
      body {
        background: #f4f4f5;
        color: #020202;
      }
      .navbar-dark {
        background-image: -webkit-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: -o-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: linear-gradient(to bottom, #005f85 0, #002e49 100%);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff005f85', endColorstr='#ff002e49', GradientType=0);
        background-repeat: repeat-x;
      }
      .navbar-dark .navbar-nav .nav-link,
      .navbar-dark .navbar-nav .nav-link:focus { color: #fff }
      .navbar-dark .navbar-nav .nav-link:hover { color: #ffef68 }
      #wrapperlicious {
        margin: 0 auto;
        font: 0.9em 'Helvetica Neue', Helvetica, sans-serif;
        font-weight: normal;
        line-height: 1.5em;
        margin: 0;
        padding: 0;
      }
      #wrapperlicious h1 { font-size: 1.5em }
      #wrapperlicious h2 { font-size: 1.3em }
      #wrapperlicious h3 { font-size: 1.1em }
      #wrapperlicious h4 { font-size: 0.9em }
      #wrapperlicious h1, #wrapperlicious h2, #wrapperlicious h3,
      #wrapperlicious h4, #wrapperlicious dt {
        color: #020202;
        margin-top: 1em;
        margin-bottom: 1em;
        position: relative;
        font-weight: bold;
      }
      #wrapperlicious a { color: inherit; text-decoration: underline }
      #wrapperlicious #toc { text-decoration: none }
      #wrapperlicious a:hover { color: #2a2a2a }
      #wrapperlicious a img { border: 0 }
      #wrapperlicious :not(pre) > code {
        color: inherit;
        background-color: rgba(0, 0, 0, 0.04);
        border-radius: 3px;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        padding: 0.3em;
      }
      #wrapperlicious dd {
        margin: 0;
        margin-left: 2em;
      }
      #wrapperlicious dt {
        color: #2a2a2a;
        font-weight: bold;
        margin-left: 0.9em;
      }
      #wrapperlicious p {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious li > p {
        margin-bottom: 0;
        margin-top: 0;
      }
      #wrapperlicious pre {
        border: 1px solid #c1c1c1;
        border-radius: 3px;
        font: 100% Consolas, Menlo, Monaco, monospace;
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious pre > code {
        display: block;
        background-color: #f6f6f6;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        line-height: 1.5em;
        text-align: left;
        white-space: pre;
        padding: 1em;
      }
      #wrapperlicious dl, #wrapperlicious ol, #wrapperlicious ul {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious ul {
        list-style-type: square;
      }
      #wrapperlicious ul ul {
        margin-bottom: 0px;
        margin-top: 0px;
      }
      #footer {
        font-size: 0.8em;
        padding-top: 0.5em;
        text-align: center;
      }
      #more {
        display: inline;
        font-size: 0.8em;
      }
      #perldocdiv {
        background-color: #fff;
        border: 1px solid #c1c1c1;
        border-bottom-left-radius: 5px;
        border-bottom-right-radius: 5px;
        margin-left: auto;
        margin-right: auto;
        padding: 3em;
        padding-top: 1em;
        max-width: 960px;
      }
      #moduleversion { float: right }
      #wrapperlicious .leading-notice {
        font-style: italic;
        padding-left: 1em;
        margin-top: 1em;
        margin-bottom: 1em;
      }
      #wrapperlicious .permalink {
        display: none;
        left: -0.75em;
        position: absolute;
        padding-right: 0.25em;
        text-decoration: none;
      }
      #wrapperlicious h1:hover .permalink, #wrapperlicious h2:hover .permalink,
      #wrapperlicious h3:hover .permalink, #wrapperlicious h4:hover .permalink,
      #wrapperlicious dt:hover .permalink {
        display: block;
      }
    </style>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-KVNWBNT5FB"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-KVNWBNT5FB');
      gtag('config', 'UA-50555-3');
    </script>
  </head>
  <body>
    <nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-between">
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="https://perldoc.perl.org/">Perldoc Browser</a>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="perlvms.html#" id="dropdownlink-stable" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">5.35.0</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-stable">
          <a class="dropdown-item" href="https://perldoc.perl.org/perlvms">Latest</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.2/perlvms">5.38.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.1/perlvms">5.38.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0/perlvms">5.38.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.3/perlvms">5.36.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.2/perlvms">5.36.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.1/perlvms">5.36.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.0/perlvms">5.36.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.3/perlvms">5.34.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.2/perlvms">5.34.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.1/perlvms">5.34.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.0/perlvms">5.34.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.1/perlvms">5.32.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.0/perlvms">5.32.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.3/perlvms">5.30.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.2/perlvms">5.30.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.1/perlvms">5.30.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.0/perlvms">5.30.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.3/perlvms">5.28.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.2/perlvms">5.28.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.1/perlvms">5.28.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.0/perlvms">5.28.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.3/perlvms">5.26.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.2/perlvms">5.26.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.1/perlvms">5.26.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.0/perlvms">5.26.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.4/perlvms">5.24.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.3/perlvms">5.24.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.2/perlvms">5.24.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.1/perlvms">5.24.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.0/perlvms">5.24.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.4/perlvms">5.22.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.3/perlvms">5.22.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.2/perlvms">5.22.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.1/perlvms">5.22.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.0/perlvms">5.22.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.3/perlvms">5.20.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.2/perlvms">5.20.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.1/perlvms">5.20.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.0/perlvms">5.20.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.4/perlvms">5.18.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.3/perlvms">5.18.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.2/perlvms">5.18.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.1/perlvms">5.18.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.0/perlvms">5.18.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.3/perlvms">5.16.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.2/perlvms">5.16.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.1/perlvms">5.16.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.0/perlvms">5.16.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.4/perlvms">5.14.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.3/perlvms">5.14.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.2/perlvms">5.14.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.1/perlvms">5.14.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.0/perlvms">5.14.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.5/perlvms">5.12.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.4/perlvms">5.12.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.3/perlvms">5.12.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.2/perlvms">5.12.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.1/perlvms">5.12.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.0/perlvms">5.12.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.1/perlvms">5.10.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.0/perlvms">5.10.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.9/perlvms">5.8.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.8/perlvms">5.8.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.7/perlvms">5.8.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.6/perlvms">5.8.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.5/perlvms">5.8.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.4/perlvms">5.8.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.3/perlvms">5.8.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.2/perlvms">5.8.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.1/perlvms">5.8.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.0/perlvms">5.8.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.2/perlvms">5.6.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.1/perlvms">5.6.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.0/perlvms">5.6.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_04/perlvms">5.005_04</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_03/perlvms">5.005_03</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_02/perlvms">5.005_02</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_01/perlvms">5.005_01</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005/perlvms">5.005</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="perlvms.html#" id="dropdownlink-dev" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dev</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-dev">
          <a class="dropdown-item" href="https://perldoc.perl.org/blead/perlvms">blead</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.6/perlvms">5.39.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.5/perlvms">5.39.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.4/perlvms">5.39.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.3/perlvms">5.39.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.2/perlvms">5.39.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.1/perlvms">5.39.1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC2/perlvms">5.38.0-RC2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC1/perlvms">5.38.0-RC1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.11/perlvms">5.37.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.10/perlvms">5.37.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.9/perlvms">5.37.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.8/perlvms">5.37.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.7/perlvms">5.37.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.6/perlvms">5.37.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.5/perlvms">5.37.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.4/perlvms">5.37.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.3/perlvms">5.37.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.2/perlvms">5.37.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.1/perlvms">5.37.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.0/perlvms">5.37.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.11/perlvms">5.35.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.10/perlvms">5.35.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.9/perlvms">5.35.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.8/perlvms">5.35.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.7/perlvms">5.35.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.6/perlvms">5.35.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.5/perlvms">5.35.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.4/perlvms">5.35.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.3/perlvms">5.35.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.2/perlvms">5.35.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.1/perlvms">5.35.1</a>
          <a class="dropdown-item active" href="perlvms.html">5.35.0</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="perlvms.html#" id="dropdownlink-nav" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Documentation</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-nav">
          <a class="dropdown-item" href="perl.html">Perl</a>
          <a class="dropdown-item" href="perlintro.html">Intro</a>
          <a class="dropdown-item" href="perl.html#Tutorials">Tutorials</a>
          <a class="dropdown-item" href="perlfaq.html">FAQs</a>
          <a class="dropdown-item" href="perl.html#Reference-Manual">Reference</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlop.html">Operators</a>
          <a class="dropdown-item" href="functions.html">Functions</a>
          <a class="dropdown-item" href="variables.html">Variables</a>
          <a class="dropdown-item" href="modules.html">Modules</a>
          <a class="dropdown-item" href="perlutil.html">Utilities</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlcommunity.html">Community</a>
          <a class="dropdown-item" href="perlhist.html">History</a>
        </div>
      </li>
    </ul>
    <ul class="navbar-nav">
      <script>
        function set_expand (expand) {
          var perldocdiv = document.getElementById('perldocdiv');
          var width = window.getComputedStyle(perldocdiv).getPropertyValue('max-width');
          var expanded = (width == '' || width == 'none') ? true : false;
          if (expand === null) {
            expand = !expanded;
          }
          if ((expand && !expanded) || (!expand && expanded)) {
            perldocdiv.style.setProperty('max-width', expand ? 'none' : '960px');
            var button_classlist = document.getElementById('content-expand-button').classList;
            if (expand) {
              button_classlist.add('btn-light');
              button_classlist.remove('btn-outline-light');
            } else {
              button_classlist.add('btn-outline-light');
              button_classlist.remove('btn-light');
            }
          }
          return expand;
        }
        function toggle_expand () {
          var expand = set_expand(null);
          document.cookie = 'perldoc_expand=' + (expand ? 1 : 0) + '; path=/; expires=Tue, 19 Jan 2038 03:14:07 UTC';
        }
        function read_expand () {
          return document.cookie.split(';').some(function (item) { return item.indexOf('perldoc_expand=1') >= 0 });
        }
        if (document.readyState === 'loading') {
          document.addEventListener('DOMContentLoaded', function () {
            if (read_expand()) {
              set_expand(true);
            }
          });
        } else if (read_expand()) {
          set_expand(true);
        }
      </script>
      <button id="content-expand-button" type="button" class="btn btn-outline-light d-none d-lg-inline-block mr-2" onclick="toggle_expand()">Expand</button>
    <ul>
    <form class="form-inline" method="get" action="https://perldoc.perl.org/5.35.0/search">
      <input class="form-control mr-3" type="search" name="q" placeholder="Search" aria-label="Search">
    </form>
  </div>
</nav>

    <div id="wrapperlicious" class="container-fluid">
      <div id="perldocdiv">
        <div id="links">
          <a href="perlvms.html">perlvms</a>
          <div id="more">
            (<a href="perlvms.txt">source</a>,
            <a href="https://metacpan.org/pod/perlvms">CPAN</a>)
          </div>
        </div>
        <div class="leading-notice">
          You are viewing the version of this documentation from Perl 5.35.0.
            This is a development version of Perl.
        </div>
        <h1><a id="toc">CONTENTS</a></h1>
                  <ul>
              <li>
                <a class="text-decoration-none" href="perlvms.html#NAME">NAME</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlvms.html#DESCRIPTION">DESCRIPTION</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlvms.html#Installation">Installation</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlvms.html#Organization-of-Perl-Images">Organization of Perl Images</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="perlvms.html#Core-Images">Core Images</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlvms.html#Perl-Extensions">Perl Extensions</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlvms.html#Installing-static-extensions">Installing static extensions</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlvms.html#Installing-dynamic-extensions">Installing dynamic extensions</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="perlvms.html#File-specifications">File specifications</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="perlvms.html#Syntax">Syntax</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlvms.html#Filename-Case">Filename Case</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlvms.html#Symbolic-Links">Symbolic Links</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlvms.html#Wildcard-expansion">Wildcard expansion</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlvms.html#Pipes">Pipes</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="perlvms.html#PERL5LIB-and-PERLLIB">PERL5LIB and PERLLIB</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlvms.html#The-Perl-Forked-Debugger">The Perl Forked Debugger</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlvms.html#PERL_VMS_EXCEPTION_DEBUG">PERL_VMS_EXCEPTION_DEBUG</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlvms.html#Command-line">Command line</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="perlvms.html#I/O-redirection-and-backgrounding">I/O redirection and backgrounding</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlvms.html#Command-line-switches">Command line switches</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="perlvms.html#Perl-functions">Perl functions</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlvms.html#Perl-variables">Perl variables</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlvms.html#Standard-modules-with-VMS-specific-differences">Standard modules with VMS-specific differences</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="perlvms.html#SDBM_File">SDBM_File</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="perlvms.html#Revision-date">Revision date</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlvms.html#AUTHOR">AUTHOR</a>
              </li>
          </ul>

      <h1 id="NAME"><a class="permalink" href="perlvms.html#NAME">#</a>NAME</h1>

<p>perlvms - VMS-specific documentation for Perl</p>

<h1 id="DESCRIPTION"><a class="permalink" href="perlvms.html#DESCRIPTION">#</a>DESCRIPTION</h1>

<p>Gathered below are notes describing details of Perl 5&#39;s behavior on VMS. They are a supplement to the regular Perl 5 documentation, so we have focussed on the ways in which Perl 5 functions differently under VMS than it does under Unix, and on the interactions between Perl and the rest of the operating system. We haven&#39;t tried to duplicate complete descriptions of Perl features from the main Perl documentation, which can be found in the <i>[.pod]</i> subdirectory of the Perl distribution.</p>

<p>We hope these notes will save you from confusion and lost sleep when writing Perl scripts on VMS. If you find we&#39;ve missed something you think should appear here, please don&#39;t hesitate to drop a line to vmsperl@perl.org.</p>

<h1 id="Installation"><a class="permalink" href="perlvms.html#Installation">#</a>Installation</h1>

<p>Directions for building and installing Perl 5 can be found in the file <i>README.vms</i> in the main source directory of the Perl distribution.</p>

<h1 id="Organization-of-Perl-Images"><a class="permalink" href="perlvms.html#Organization-of-Perl-Images">#</a><a id="Organization"></a>Organization of Perl Images</h1>

<h2 id="Core-Images"><a class="permalink" href="perlvms.html#Core-Images">#</a><a id="Core"></a>Core Images</h2>

<p>During the build process, three Perl images are produced. <i>Miniperl.Exe</i> is an executable image which contains all of the basic functionality of Perl, but cannot take advantage of Perl XS extensions and has a hard-wired list of library locations for loading pure-Perl modules. It is used extensively to build and test Perl and various extensions, but is not installed.</p>

<p>Most of the complete Perl resides in the shareable image <i>PerlShr.Exe</i>, which provides a core to which the Perl executable image and all Perl extensions are linked. It is generally located via the logical name <i>PERLSHR</i>. While it&#39;s possible to put the image in <i>SYS$SHARE</i> to make it loadable, that&#39;s not recommended. And while you may wish to INSTALL the image for performance reasons, you should not install it with privileges; if you do, the result will not be what you expect as image privileges are disabled during Perl start-up.</p>

<p>Finally, <i>Perl.Exe</i> is an executable image containing the main entry point for Perl, as well as some initialization code. It should be placed in a public directory, and made world executable. In order to run Perl with command line arguments, you should define a foreign command to invoke this image.</p>

<h2 id="Perl-Extensions"><a class="permalink" href="perlvms.html#Perl-Extensions">#</a><a id="Perl"></a>Perl Extensions</h2>

<p>Perl extensions are packages which provide both XS and Perl code to add new functionality to perl. (XS is a meta-language which simplifies writing C code which interacts with Perl, see <a href="perlxs.html">perlxs</a> for more details.) The Perl code for an extension is treated like any other library module - it&#39;s made available in your script through the appropriate <code>use</code> or <code>require</code> statement, and usually defines a Perl package containing the extension.</p>

<p>The portion of the extension provided by the XS code may be connected to the rest of Perl in either of two ways. In the <b>static</b> configuration, the object code for the extension is linked directly into <i>PerlShr.Exe</i>, and is initialized whenever Perl is invoked. In the <b>dynamic</b> configuration, the extension&#39;s machine code is placed into a separate shareable image, which is mapped by Perl&#39;s DynaLoader when the extension is <code>use</code>d or <code>require</code>d in your script. This allows you to maintain the extension as a separate entity, at the cost of keeping track of the additional shareable image. Most extensions can be set up as either static or dynamic.</p>

<p>The source code for an extension usually resides in its own directory. At least three files are generally provided: <i>Extshortname</i><i>.xs</i> (where <i>Extshortname</i> is the portion of the extension&#39;s name following the last <code>::</code>), containing the XS code, <i>Extshortname</i><i>.pm</i>, the Perl library module for the extension, and <i>Makefile.PL</i>, a Perl script which uses the <code>MakeMaker</code> library modules supplied with Perl to generate a <i>Descrip.MMS</i> file for the extension.</p>

<h2 id="Installing-static-extensions"><a class="permalink" href="perlvms.html#Installing-static-extensions">#</a><a id="Installing"></a>Installing static extensions</h2>

<p>Since static extensions are incorporated directly into <i>PerlShr.Exe</i>, you&#39;ll have to rebuild Perl to incorporate a new extension. You should edit the main <i>Descrip.MMS</i> or <i>Makefile</i> you use to build Perl, adding the extension&#39;s name to the <code>ext</code> macro, and the extension&#39;s object file to the <code>extobj</code> macro. You&#39;ll also need to build the extension&#39;s object file, either by adding dependencies to the main <i>Descrip.MMS</i>, or using a separate <i>Descrip.MMS</i> for the extension. Then, rebuild <i>PerlShr.Exe</i> to incorporate the new code.</p>

<p>Finally, you&#39;ll need to copy the extension&#39;s Perl library module to the <i>[.</i><i>Extname</i><i>]</i> subdirectory under one of the directories in <code>@INC</code>, where <i>Extname</i> is the name of the extension, with all <code>::</code> replaced by <code>.</code> (e.g. the library module for extension Foo::Bar would be copied to a <i>[.Foo.Bar]</i> subdirectory).</p>

<h2 id="Installing-dynamic-extensions"><a class="permalink" href="perlvms.html#Installing-dynamic-extensions">#</a><a id="Installing1"></a>Installing dynamic extensions</h2>

<p>In general, the distributed kit for a Perl extension includes a file named Makefile.PL, which is a Perl program which is used to create a <i>Descrip.MMS</i> file which can be used to build and install the files required by the extension. The kit should be unpacked into a directory tree <b>not</b> under the main Perl source directory, and the procedure for building the extension is simply</p>

<pre><code class="plaintext">$ perl Makefile.PL  ! Create Descrip.MMS
$ mmk               ! Build necessary files
$ mmk test          ! Run test code, if supplied
$ mmk install       ! Install into public Perl tree</code></pre>

<p>VMS support for this process in the current release of Perl is sufficient to handle most extensions. (See the MakeMaker documentation for more details on installation options for extensions.)</p>

<ul>

<li><p>the <i>[.Lib.Auto.</i><i>Arch</i><i>$PVers</i><i>Extname</i><i>]</i> subdirectory of one of the directories in <code>@INC</code> (where <i>PVers</i> is the version of Perl you&#39;re using, as supplied in <code>$]</code>, with &#39;.&#39; converted to &#39;_&#39;), or</p>

</li>
<li><p>one of the directories in <code>@INC</code>, or</p>

</li>
<li><p>a directory which the extensions Perl library module passes to the DynaLoader when asking it to map the shareable image, or</p>

</li>
<li><p><i>Sys$Share</i> or <i>Sys$Library</i>.</p>

</li>
</ul>

<p>If the shareable image isn&#39;t in any of these places, you&#39;ll need to define a logical name <i>Extshortname</i>, where <i>Extshortname</i> is the portion of the extension&#39;s name after the last <code>::</code>, which translates to the full file specification of the shareable image.</p>

<h1 id="File-specifications"><a class="permalink" href="perlvms.html#File-specifications">#</a><a id="File"></a>File specifications</h1>

<h2 id="Syntax"><a class="permalink" href="perlvms.html#Syntax">#</a>Syntax</h2>

<p>We have tried to make Perl aware of both VMS-style and Unix-style file specifications wherever possible. You may use either style, or both, on the command line and in scripts, but you may not combine the two styles within a single file specification. VMS Perl interprets Unix pathnames in much the same way as the CRTL (<i>e.g.</i> the first component of an absolute path is read as the device name for the VMS file specification). There are a set of functions provided in the <code>VMS::Filespec</code> package for explicit interconversion between VMS and Unix syntax; its documentation provides more details.</p>

<p>We&#39;ve tried to minimize the dependence of Perl library modules on Unix syntax, but you may find that some of these, as well as some scripts written for Unix systems, will require that you use Unix syntax, since they will assume that &#39;/&#39; is the directory separator, <i>etc.</i> If you find instances of this in the Perl distribution itself, please let us know, so we can try to work around them.</p>

<p>Also when working on Perl programs on VMS, if you need a syntax in a specific operating system format, then you need either to check the appropriate DECC$ feature logical, or call a conversion routine to force it to that format.</p>

<p>The feature logical name DECC$FILENAME_UNIX_REPORT modifies traditional Perl behavior in the conversion of file specifications from Unix to VMS format in order to follow the extended character handling rules now expected by the CRTL. Specifically, when this feature is in effect, the <code>./.../</code> in a Unix path is now translated to <code>[.^.^.^.]</code> instead of the traditional VMS <code>[...]</code>. To be compatible with what MakeMaker expects, if a VMS path cannot be translated to a Unix path, it is passed through unchanged, so <code>unixify(&quot;[...]&quot;)</code> will return <code>[...]</code>.</p>

<p>There are several ambiguous cases where a conversion routine cannot determine whether an input filename is in Unix format or in VMS format, since now both VMS and Unix file specifications may have characters in them that could be mistaken for syntax delimiters of the other type. So some pathnames simply cannot be used in a mode that allows either type of pathname to be present. Perl will tend to assume that an ambiguous filename is in Unix format.</p>

<p>Allowing &quot;.&quot; as a version delimiter is simply incompatible with determining whether a pathname is in VMS format or in Unix format with extended file syntax. There is no way to know whether &quot;perl-5.8.6&quot; is a Unix &quot;perl-5.8.6&quot; or a VMS &quot;perl-5.8;6&quot; when passing it to unixify() or vmsify().</p>

<p>The DECC$FILENAME_UNIX_REPORT logical name controls how Perl interprets filenames to the extent that Perl uses the CRTL internally for many purposes, and attempts to follow CRTL conventions for reporting filenames. The DECC$FILENAME_UNIX_ONLY feature differs in that it expects all filenames passed to the C run-time to be already in Unix format. This feature is not yet supported in Perl since Perl uses traditional OpenVMS file specifications internally and in the test harness, and it is not yet clear whether this mode will be useful or useable. The feature logical name DECC$POSIX_COMPLIANT_PATHNAMES is new with the RMS Symbolic Link SDK and included with OpenVMS v8.3, but is not yet supported in Perl.</p>

<h2 id="Filename-Case"><a class="permalink" href="perlvms.html#Filename-Case">#</a><a id="Filename"></a>Filename Case</h2>

<p>Perl enables DECC$EFS_CASE_PRESERVE and DECC$ARGV_PARSE_STYLE by default. Note that the latter only takes effect when extended parse is set in the process in which Perl is running. When these features are explicitly disabled in the environment or the CRTL does not support them, Perl follows the traditional CRTL behavior of downcasing command-line arguments and returning file specifications in lower case only.</p>

<p><i>N. B.</i> It is very easy to get tripped up using a mixture of other programs, external utilities, and Perl scripts that are in varying states of being able to handle case preservation. For example, a file created by an older version of an archive utility or a build utility such as MMK or MMS may generate a filename in all upper case even on an ODS-5 volume. If this filename is later retrieved by a Perl script or module in a case preserving environment, that upper case name may not match the mixed-case or lower-case expectations of the Perl code. Your best bet is to follow an all-or-nothing approach to case preservation: either don&#39;t use it at all, or make sure your entire toolchain and application environment support and use it.</p>

<p>OpenVMS Alpha v7.3-1 and later and all version of OpenVMS I64 support case sensitivity as a process setting (see <code>SET PROCESS /CASE_LOOKUP=SENSITIVE</code>). Perl does not currently support case sensitivity on VMS, but it may in the future, so Perl programs should use the <code>File::Spec-&gt;case_tolerant</code> method to determine the state, and not the <code>$^O</code> variable.</p>

<h2 id="Symbolic-Links"><a class="permalink" href="perlvms.html#Symbolic-Links">#</a><a id="Symbolic"></a>Symbolic Links</h2>

<p>When built on an ODS-5 volume with symbolic links enabled, Perl by default supports symbolic links when the requisite support is available in the filesystem and CRTL (generally 64-bit OpenVMS v8.3 and later). There are a number of limitations and caveats to be aware of when working with symbolic links on VMS. Most notably, the target of a valid symbolic link must be expressed as a Unix-style path and it must exist on a volume visible from your POSIX root (see the <code>SHOW ROOT</code> command in DCL help). For further details on symbolic link capabilities and requirements, see chapter 12 of the CRTL manual that ships with OpenVMS v8.3 or later.</p>

<h2 id="Wildcard-expansion"><a class="permalink" href="perlvms.html#Wildcard-expansion">#</a><a id="Wildcard"></a>Wildcard expansion</h2>

<p>File specifications containing wildcards are allowed both on the command line and within Perl globs (e.g. <code>&lt;*.c&gt;</code>). If the wildcard filespec uses VMS syntax, the resultant filespecs will follow VMS syntax; if a Unix-style filespec is passed in, Unix-style filespecs will be returned. Similar to the behavior of wildcard globbing for a Unix shell, one can escape command line wildcards with double quotation marks <code>&quot;</code> around a perl program command line argument. However, owing to the stripping of <code>&quot;</code> characters carried out by the C handling of argv you will need to escape a construct such as this one (in a directory containing the files <i>PERL.C</i>, <i>PERL.EXE</i>, <i>PERL.H</i>, and <i>PERL.OBJ</i>):</p>

<pre><code>$ perl -e &quot;print join(&#39; &#39;,@ARGV)&quot; perl.*
perl.c perl.exe perl.h perl.obj</code></pre>

<p>in the following triple quoted manner:</p>

<pre><code>$ perl -e &quot;print join(&#39; &#39;,@ARGV)&quot; &quot;&quot;&quot;perl.*&quot;&quot;&quot;
perl.*</code></pre>

<p>In both the case of unquoted command line arguments or in calls to <code>glob()</code> VMS wildcard expansion is performed. (csh-style wildcard expansion is available if you use <code>File::Glob::glob</code>.) If the wildcard filespec contains a device or directory specification, then the resultant filespecs will also contain a device and directory; otherwise, device and directory information are removed. VMS-style resultant filespecs will contain a full device and directory, while Unix-style resultant filespecs will contain only as much of a directory path as was present in the input filespec. For example, if your default directory is Perl_Root:[000000], the expansion of <code>[.t]*.*</code> will yield filespecs like &quot;perl_root:[t]base.dir&quot;, while the expansion of <code>t/*/*</code> will yield filespecs like &quot;t/base.dir&quot;. (This is done to match the behavior of glob expansion performed by Unix shells.)</p>

<p>Similarly, the resultant filespec will contain the file version only if one was present in the input filespec.</p>

<h2 id="Pipes"><a class="permalink" href="perlvms.html#Pipes">#</a>Pipes</h2>

<p>Input and output pipes to Perl filehandles are supported; the &quot;file name&quot; is passed to lib$spawn() for asynchronous execution. You should be careful to close any pipes you have opened in a Perl script, lest you leave any &quot;orphaned&quot; subprocesses around when Perl exits.</p>

<p>You may also use backticks to invoke a DCL subprocess, whose output is used as the return value of the expression. The string between the backticks is handled as if it were the argument to the <code>system</code> operator (see below). In this case, Perl will wait for the subprocess to complete before continuing.</p>

<p>The mailbox (MBX) that perl can create to communicate with a pipe defaults to a buffer size of 8192 on 64-bit systems, 512 on VAX. The default buffer size is adjustable via the logical name PERL_MBX_SIZE provided that the value falls between 128 and the SYSGEN parameter MAXBUF inclusive. For example, to set the mailbox size to 32767 use <code>$ENV{&#39;PERL_MBX_SIZE&#39;} = 32767;</code> and then open and use pipe constructs. An alternative would be to issue the command:</p>

<pre><code class="plaintext">$ Define PERL_MBX_SIZE 32767</code></pre>

<p>before running your wide record pipe program. A larger value may improve performance at the expense of the BYTLM UAF quota.</p>

<h1 id="PERL5LIB-and-PERLLIB"><a class="permalink" href="perlvms.html#PERL5LIB-and-PERLLIB">#</a><a id="PERL5LIB"></a>PERL5LIB and PERLLIB</h1>

<p>The PERL5LIB and PERLLIB environment elements work as documented in <a href="perl.html">perl</a>, except that the element separator is, by default, &#39;|&#39; instead of &#39;:&#39;. However, when running under a Unix shell as determined by the logical name <code>GNV$UNIX_SHELL</code>, the separator will be &#39;:&#39; as on Unix systems. The directory specifications may use either VMS or Unix syntax.</p>

<h1 id="The-Perl-Forked-Debugger"><a class="permalink" href="perlvms.html#The-Perl-Forked-Debugger">#</a><a id="The"></a>The Perl Forked Debugger</h1>

<p>The Perl forked debugger places the debugger commands and output in a separate X-11 terminal window so that commands and output from multiple processes are not mixed together.</p>

<p>Perl on VMS supports an emulation of the forked debugger when Perl is run on a VMS system that has X11 support installed.</p>

<p>To use the forked debugger, you need to have the default display set to an X-11 Server and some environment variables set that Unix expects.</p>

<p>The forked debugger requires the environment variable <code>TERM</code> to be <code>xterm</code>, and the environment variable <code>DISPLAY</code> to exist. <code>xterm</code> must be in lower case.</p>

<pre><code>$define TERM &quot;xterm&quot;

$define DISPLAY &quot;hostname:0.0&quot;</code></pre>

<p>Currently the value of <code>DISPLAY</code> is ignored. It is recommended that it be set to be the hostname of the display, the server and screen in Unix notation. In the future the value of DISPLAY may be honored by Perl instead of using the default display.</p>

<p>It may be helpful to always use the forked debugger so that script I/O is separated from debugger I/O. You can force the debugger to be forked by assigning a value to the logical name &lt;PERLDB_PIDS&gt; that is not a process identification number.</p>

<pre><code>$define PERLDB_PIDS XXXX</code></pre>

<h1 id="PERL_VMS_EXCEPTION_DEBUG"><a class="permalink" href="perlvms.html#PERL_VMS_EXCEPTION_DEBUG">#</a>PERL_VMS_EXCEPTION_DEBUG</h1>

<p>The PERL_VMS_EXCEPTION_DEBUG being defined as &quot;ENABLE&quot; will cause the VMS debugger to be invoked if a fatal exception that is not otherwise handled is raised. The purpose of this is to allow debugging of internal Perl problems that would cause such a condition.</p>

<p>This allows the programmer to look at the execution stack and variables to find out the cause of the exception. As the debugger is being invoked as the Perl interpreter is about to do a fatal exit, continuing the execution in debug mode is usually not practical.</p>

<p>Starting Perl in the VMS debugger may change the program execution profile in a way that such problems are not reproduced.</p>

<p>The <code>kill</code> function can be used to test this functionality from within a program.</p>

<p>In typical VMS style, only the first letter of the value of this logical name is actually checked in a case insensitive mode, and it is considered enabled if it is the value &quot;T&quot;,&quot;1&quot; or &quot;E&quot;.</p>

<p>This logical name must be defined before Perl is started.</p>

<h1 id="Command-line"><a class="permalink" href="perlvms.html#Command-line">#</a><a id="Command"></a>Command line</h1>

<h2 id="I/O-redirection-and-backgrounding"><a class="permalink" href="perlvms.html#I/O-redirection-and-backgrounding">#</a><a id="I"></a><a id="I-O-redirection-and-backgrounding"></a>I/O redirection and backgrounding</h2>

<p>Perl for VMS supports redirection of input and output on the command line, using a subset of Bourne shell syntax:</p>

<ul>

<li><p><code>&lt;file</code> reads stdin from <code>file</code>,</p>

</li>
<li><p><code>&gt;file</code> writes stdout to <code>file</code>,</p>

</li>
<li><p><code>&gt;&gt;file</code> appends stdout to <code>file</code>,</p>

</li>
<li><p><code>2&gt;file</code> writes stderr to <code>file</code>,</p>

</li>
<li><p><code>2&gt;&gt;file</code> appends stderr to <code>file</code>, and</p>

</li>
<li><p><code>2&gt;&amp;1</code> redirects stderr to stdout.</p>

</li>
</ul>

<p>In addition, output may be piped to a subprocess, using the character &#39;|&#39;. Anything after this character on the command line is passed to a subprocess for execution; the subprocess takes the output of Perl as its input.</p>

<p>Finally, if the command line ends with &#39;&amp;&#39;, the entire command is run in the background as an asynchronous subprocess.</p>

<h2 id="Command-line-switches"><a class="permalink" href="perlvms.html#Command-line-switches">#</a><a id="Command1"></a>Command line switches</h2>

<p>The following command line switches behave differently under VMS than described in <a href="perlrun.html">perlrun</a>. Note also that in order to pass uppercase switches to Perl, you need to enclose them in double-quotes on the command line, since the CRTL downcases all unquoted strings.</p>

<p>On newer 64 bit versions of OpenVMS, a process setting now controls if the quoting is needed to preserve the case of command line arguments.</p>

<dl>

<dt id="-i"><a class="permalink" href="perlvms.html#-i">#</a><a id="i"></a>-i</dt>
<dd>

<p>If the <code>-i</code> switch is present but no extension for a backup copy is given, then inplace editing creates a new version of a file; the existing copy is not deleted. (Note that if an extension is given, an existing file is renamed to the backup file, as is the case under other operating systems, so it does not remain as a previous version under the original filename.)</p>

</dd>
<dt id="-S"><a class="permalink" href="perlvms.html#-S">#</a><a id="S"></a>-S</dt>
<dd>

<p>If the <code>&quot;-S&quot;</code> or <code>-&quot;S&quot;</code> switch is present <i>and</i> the script name does not contain a directory, then Perl translates the logical name DCL$PATH as a searchlist, using each translation as a directory in which to look for the script. In addition, if no file type is specified, Perl looks in each directory for a file matching the name specified, with a blank type, a type of <i>.pl</i>, and a type of <i>.com</i>, in that order.</p>

</dd>
<dt id="-u"><a class="permalink" href="perlvms.html#-u">#</a><a id="u"></a>-u</dt>
<dd>

<p>The <code>-u</code> switch causes the VMS debugger to be invoked after the Perl program is compiled, but before it has run. It does not create a core dump file.</p>

</dd>
</dl>

<h1 id="Perl-functions"><a class="permalink" href="perlvms.html#Perl-functions">#</a><a id="Perl1"></a>Perl functions</h1>

<p>As of the time this document was last revised, the following Perl functions were implemented in the VMS port of Perl (functions marked with * are discussed in more detail below):</p>

<pre><code class="plaintext">file tests*, abs, alarm, atan, backticks*, binmode*, bless,
caller, chdir, chmod, chown, chomp, chop, chr,
close, closedir, cos, crypt*, defined, delete, die, do, dump*, 
each, endgrent, endpwent, eof, eval, exec*, exists, exit, exp, 
fileno, flock  getc, getgrent*, getgrgid*, getgrnam, getlogin,
getppid, getpwent*, getpwnam*, getpwuid*, glob, gmtime*, goto,
grep, hex, ioctl, import, index, int, join, keys, kill*,
last, lc, lcfirst, lchown*, length, link*, local, localtime, log,
lstat, m//, map, mkdir, my, next, no, oct, open, opendir, ord,
pack, pipe, pop, pos, print, printf, push, q//, qq//, qw//,
qx//*, quotemeta, rand, read, readdir, readlink*, redo, ref,
rename, require, reset, return, reverse, rewinddir, rindex,
rmdir, s///, scalar, seek, seekdir, select(internal),
select (system call)*, setgrent, setpwent, shift, sin, sleep,
socketpair, sort, splice, split, sprintf, sqrt, srand, stat,
study, substr, symlink*, sysread, system*, syswrite, tell,
telldir, tie, time, times*, tr///, uc, ucfirst, umask,
undef, unlink*, unpack, untie, unshift, use, utime*,
values, vec, wait, waitpid*, wantarray, warn, write, y///</code></pre>

<p>The following functions were not implemented in the VMS port, and calling them produces a fatal error (usually) or undefined behavior (rarely, we hope):</p>

<pre><code class="plaintext">chroot, dbmclose, dbmopen, fork*, getpgrp, getpriority,  
msgctl, msgget, msgsend, msgrcv, semctl,
semget, semop, setpgrp, setpriority, shmctl, shmget,
shmread, shmwrite, syscall</code></pre>

<p>The following functions are available on Perls compiled with Dec C 5.2 or greater and running VMS 7.0 or greater:</p>

<pre><code class="plaintext">truncate</code></pre>

<p>The following functions are available on Perls built on VMS 7.2 or greater:</p>

<pre><code class="plaintext">fcntl (without locking)</code></pre>

<p>The following functions may or may not be implemented, depending on what type of socket support you&#39;ve built into your copy of Perl:</p>

<pre><code class="plaintext">accept, bind, connect, getpeername,
gethostbyname, getnetbyname, getprotobyname,
getservbyname, gethostbyaddr, getnetbyaddr,
getprotobynumber, getservbyport, gethostent,
getnetent, getprotoent, getservent, sethostent,
setnetent, setprotoent, setservent, endhostent,
endnetent, endprotoent, endservent, getsockname,
getsockopt, listen, recv, select(system call)*,
send, setsockopt, shutdown, socket</code></pre>

<p>The following function is available on Perls built on 64 bit OpenVMS v8.2 with hard links enabled on an ODS-5 formatted build disk. CRTL support is in principle available as of OpenVMS v7.3-1, and better configuration support could detect this.</p>

<pre><code class="plaintext">link</code></pre>

<p>The following functions are available on Perls built on 64 bit OpenVMS v8.2 and later. CRTL support is in principle available as of OpenVMS v7.3-2, and better configuration support could detect this.</p>

<pre><code class="plaintext">getgrgid, getgrnam, getpwnam, getpwuid,
setgrent, ttyname</code></pre>

<p>The following functions are available on Perls built on 64 bit OpenVMS v8.2 and later.</p>

<pre><code class="plaintext">statvfs, socketpair</code></pre>

<dl>

<dt id="File-tests"><a class="permalink" href="perlvms.html#File-tests">#</a><a id="File1"></a>File tests</dt>
<dd>

<p>The tests <code>-b</code>, <code>-B</code>, <code>-c</code>, <code>-C</code>, <code>-d</code>, <code>-e</code>, <code>-f</code>, <code>-o</code>, <code>-M</code>, <code>-s</code>, <code>-S</code>, <code>-t</code>, <code>-T</code>, and <code>-z</code> work as advertised. The return values for <code>-r</code>, <code>-w</code>, and <code>-x</code> tell you whether you can actually access the file; this may not reflect the UIC-based file protections. Since real and effective UIC don&#39;t differ under VMS, <code>-O</code>, <code>-R</code>, <code>-W</code>, and <code>-X</code> are equivalent to <code>-o</code>, <code>-r</code>, <code>-w</code>, and <code>-x</code>. Similarly, several other tests, including <code>-A</code>, <code>-g</code>, <code>-k</code>, <code>-l</code>, <code>-p</code>, and <code>-u</code>, aren&#39;t particularly meaningful under VMS, and the values returned by these tests reflect whatever your CRTL <code>stat()</code> routine does to the equivalent bits in the st_mode field. Finally, <code>-d</code> returns true if passed a device specification without an explicit directory (e.g. <code>DUA1:</code>), as well as if passed a directory.</p>

<p>There are DECC feature logical names AND ODS-5 volume attributes that also control what values are returned for the date fields.</p>

<p>Note: Some sites have reported problems when using the file-access tests (<code>-r</code>, <code>-w</code>, and <code>-x</code>) on files accessed via DEC&#39;s DFS. Specifically, since DFS does not currently provide access to the extended file header of files on remote volumes, attempts to examine the ACL fail, and the file tests will return false, with <code>$!</code> indicating that the file does not exist. You can use <code>stat</code> on these files, since that checks UIC-based protection only, and then manually check the appropriate bits, as defined by your C compiler&#39;s <i>stat.h</i>, in the mode value it returns, if you need an approximation of the file&#39;s protections.</p>

</dd>
<dt id="backticks"><a class="permalink" href="perlvms.html#backticks">#</a>backticks</dt>
<dd>

<p>Backticks create a subprocess, and pass the enclosed string to it for execution as a DCL command. Since the subprocess is created directly via <code>lib$spawn()</code>, any valid DCL command string may be specified.</p>

</dd>
<dt id="binmode-FILEHANDLE"><a class="permalink" href="perlvms.html#binmode-FILEHANDLE">#</a><a id="binmode"></a>binmode FILEHANDLE</dt>
<dd>

<p>The <code>binmode</code> operator will attempt to insure that no translation of carriage control occurs on input from or output to this filehandle. Since this involves reopening the file and then restoring its file position indicator, if this function returns FALSE, the underlying filehandle may no longer point to an open file, or may point to a different position in the file than before <code>binmode</code> was called.</p>

<p>Note that <code>binmode</code> is generally not necessary when using normal filehandles; it is provided so that you can control I/O to existing record-structured files when necessary. You can also use the <code>vmsfopen</code> function in the VMS::Stdio extension to gain finer control of I/O to files and devices with different record structures.</p>

</dd>
<dt id="crypt-PLAINTEXT,-USER"><a class="permalink" href="perlvms.html#crypt-PLAINTEXT,-USER">#</a><a id="crypt"></a><a id="crypt-PLAINTEXT-USER"></a>crypt PLAINTEXT, USER</dt>
<dd>

<p>The <code>crypt</code> operator uses the <code>sys$hash_password</code> system service to generate the hashed representation of PLAINTEXT. If USER is a valid username, the algorithm and salt values are taken from that user&#39;s UAF record. If it is not, then the preferred algorithm and a salt of 0 are used. The quadword encrypted value is returned as an 8-character string.</p>

<p>The value returned by <code>crypt</code> may be compared against the encrypted password from the UAF returned by the <code>getpw*</code> functions, in order to authenticate users. If you&#39;re going to do this, remember that the encrypted password in the UAF was generated using uppercase username and password strings; you&#39;ll have to upcase the arguments to <code>crypt</code> to insure that you&#39;ll get the proper value:</p>

<pre><code>sub validate_passwd {
    my($user,$passwd) = @_;
    my($pwdhash);
    if ( !($pwdhash = (getpwnam($user))[1]) ||
           $pwdhash ne crypt(&quot;\U$passwd&quot;,&quot;\U$name&quot;) ) {
        intruder_alert($name);
    }
    return 1;
}</code></pre>

</dd>
<dt id="die"><a class="permalink" href="perlvms.html#die">#</a>die</dt>
<dd>

<p><code>die</code> will force the native VMS exit status to be an SS$_ABORT code if neither of the $! or $? status values are ones that would cause the native status to be interpreted as being what VMS classifies as SEVERE_ERROR severity for DCL error handling.</p>

<p>When <code>PERL_VMS_POSIX_EXIT</code> is active (see <a href="perlvms.html#%24%3F">&quot;$?&quot;</a> below), the native VMS exit status value will have either one of the <code>$!</code> or <code>$?</code> or <code>$^E</code> or the Unix value 255 encoded into it in a way that the effective original value can be decoded by other programs written in C, including Perl and the GNV package. As per the normal non-VMS behavior of <code>die</code> if either <code>$!</code> or <code>$?</code> are non-zero, one of those values will be encoded into a native VMS status value. If both of the Unix status values are 0, and the <code>$^E</code> value is set one of ERROR or SEVERE_ERROR severity, then the <code>$^E</code> value will be used as the exit code as is. If none of the above apply, the Unix value of 255 will be encoded into a native VMS exit status value.</p>

<p>Please note a significant difference in the behavior of <code>die</code> in the <code>PERL_VMS_POSIX_EXIT</code> mode is that it does not force a VMS SEVERE_ERROR status on exit. The Unix exit values of 2 through 255 will be encoded in VMS status values with severity levels of SUCCESS. The Unix exit value of 1 will be encoded in a VMS status value with a severity level of ERROR. This is to be compatible with how the VMS C library encodes these values.</p>

<p>The minimum severity level set by <code>die</code> in <code>PERL_VMS_POSIX_EXIT</code> mode may be changed to be ERROR or higher in the future depending on the results of testing and further review.</p>

<p>See <a href="perlvms.html#%24%3F">&quot;$?&quot;</a> for a description of the encoding of the Unix value to produce a native VMS status containing it.</p>

</dd>
<dt id="dump"><a class="permalink" href="perlvms.html#dump">#</a>dump</dt>
<dd>

<p>Rather than causing Perl to abort and dump core, the <code>dump</code> operator invokes the VMS debugger. If you continue to execute the Perl program under the debugger, control will be transferred to the label specified as the argument to <code>dump</code>, or, if no label was specified, back to the beginning of the program. All other state of the program (<i>e.g.</i> values of variables, open file handles) are not affected by calling <code>dump</code>.</p>

</dd>
<dt id="exec-LIST"><a class="permalink" href="perlvms.html#exec-LIST">#</a><a id="exec"></a>exec LIST</dt>
<dd>

<p>A call to <code>exec</code> will cause Perl to exit, and to invoke the command given as an argument to <code>exec</code> via <code>lib$do_command</code>. If the argument begins with &#39;@&#39; or &#39;$&#39; (other than as part of a filespec), then it is executed as a DCL command. Otherwise, the first token on the command line is treated as the filespec of an image to run, and an attempt is made to invoke it (using <i>.Exe</i> and the process defaults to expand the filespec) and pass the rest of <code>exec</code>&#39;s argument to it as parameters. If the token has no file type, and matches a file with null type, then an attempt is made to determine whether the file is an executable image which should be invoked using <code>MCR</code> or a text file which should be passed to DCL as a command procedure.</p>

</dd>
<dt id="fork"><a class="permalink" href="perlvms.html#fork">#</a>fork</dt>
<dd>

<p>While in principle the <code>fork</code> operator could be implemented via (and with the same rather severe limitations as) the CRTL <code>vfork()</code> routine, and while some internal support to do just that is in place, the implementation has never been completed, making <code>fork</code> currently unavailable. A true kernel <code>fork()</code> is expected in a future version of VMS, and the pseudo-fork based on interpreter threads may be available in a future version of Perl on VMS (see <a href="perlfork.html">perlfork</a>). In the meantime, use <code>system</code>, backticks, or piped filehandles to create subprocesses.</p>

</dd>
<dt id="getpwent"><a class="permalink" href="perlvms.html#getpwent">#</a>getpwent</dt>
<dd>

</dd>
<dt id="getpwnam"><a class="permalink" href="perlvms.html#getpwnam">#</a>getpwnam</dt>
<dd>

</dd>
<dt id="getpwuid"><a class="permalink" href="perlvms.html#getpwuid">#</a>getpwuid</dt>
<dd>

<p>These operators obtain the information described in <a href="perlfunc.html">perlfunc</a>, if you have the privileges necessary to retrieve the named user&#39;s UAF information via <code>sys$getuai</code>. If not, then only the <code>$name</code>, <code>$uid</code>, and <code>$gid</code> items are returned. The <code>$dir</code> item contains the login directory in VMS syntax, while the <code>$comment</code> item contains the login directory in Unix syntax. The <code>$gcos</code> item contains the owner field from the UAF record. The <code>$quota</code> item is not used.</p>

</dd>
<dt id="gmtime"><a class="permalink" href="perlvms.html#gmtime">#</a>gmtime</dt>
<dd>

<p>The <code>gmtime</code> operator will function properly if you have a working CRTL <code>gmtime()</code> routine, or if the logical name SYS$TIMEZONE_DIFFERENTIAL is defined as the number of seconds which must be added to UTC to yield local time. (This logical name is defined automatically if you are running a version of VMS with built-in UTC support.) If neither of these cases is true, a warning message is printed, and <code>undef</code> is returned.</p>

</dd>
<dt id="kill"><a class="permalink" href="perlvms.html#kill">#</a>kill</dt>
<dd>

<p>In most cases, <code>kill</code> is implemented via the undocumented system service <code>$SIGPRC</code>, which has the same calling sequence as <code>$FORCEX</code>, but throws an exception in the target process rather than forcing it to call <code>$EXIT</code>. Generally speaking, <code>kill</code> follows the behavior of the CRTL&#39;s <code>kill()</code> function, but unlike that function can be called from within a signal handler. Also, unlike the <code>kill</code> in some versions of the CRTL, Perl&#39;s <code>kill</code> checks the validity of the signal passed in and returns an error rather than attempting to send an unrecognized signal.</p>

<p>Also, negative signal values don&#39;t do anything special under VMS; they&#39;re just converted to the corresponding positive value.</p>

</dd>
<dt id="qx//"><a class="permalink" href="perlvms.html#qx//">#</a><a id="qx"></a>qx//</dt>
<dd>

<p>See the entry on <code>backticks</code> above.</p>

</dd>
<dt id="select-(system-call)"><a class="permalink" href="perlvms.html#select-(system-call)">#</a><a id="select"></a><a id="select-system-call"></a>select (system call)</dt>
<dd>

<p>If Perl was not built with socket support, the system call version of <code>select</code> is not available at all. If socket support is present, then the system call version of <code>select</code> functions only for file descriptors attached to sockets. It will not provide information about regular files or pipes, since the CRTL <code>select()</code> routine does not provide this functionality.</p>

</dd>
<dt id="stat-EXPR"><a class="permalink" href="perlvms.html#stat-EXPR">#</a><a id="stat"></a>stat EXPR</dt>
<dd>

<p>Since VMS keeps track of files according to a different scheme than Unix, it&#39;s not really possible to represent the file&#39;s ID in the <code>st_dev</code> and <code>st_ino</code> fields of a <code>struct stat</code>. Perl tries its best, though, and the values it uses are pretty unlikely to be the same for two different files. We can&#39;t guarantee this, though, so caveat scriptor.</p>

</dd>
<dt id="system-LIST"><a class="permalink" href="perlvms.html#system-LIST">#</a><a id="system"></a>system LIST</dt>
<dd>

<p>The <code>system</code> operator creates a subprocess, and passes its arguments to the subprocess for execution as a DCL command. Since the subprocess is created directly via <code>lib$spawn()</code>, any valid DCL command string may be specified. If the string begins with &#39;@&#39;, it is treated as a DCL command unconditionally. Otherwise, if the first token contains a character used as a delimiter in file specification (e.g. <code>:</code> or <code>]</code>), an attempt is made to expand it using a default type of <i>.Exe</i> and the process defaults, and if successful, the resulting file is invoked via <code>MCR</code>. This allows you to invoke an image directly simply by passing the file specification to <code>system</code>, a common Unixish idiom. If the token has no file type, and matches a file with null type, then an attempt is made to determine whether the file is an executable image which should be invoked using <code>MCR</code> or a text file which should be passed to DCL as a command procedure.</p>

<p>If LIST consists of the empty string, <code>system</code> spawns an interactive DCL subprocess, in the same fashion as typing <b>SPAWN</b> at the DCL prompt.</p>

<p>Perl waits for the subprocess to complete before continuing execution in the current process. As described in <a href="perlfunc.html">perlfunc</a>, the return value of <code>system</code> is a fake &quot;status&quot; which follows POSIX semantics unless the pragma <code>use vmsish &#39;status&#39;</code> is in effect; see the description of <code>$?</code> in this document for more detail.</p>

</dd>
<dt id="time"><a class="permalink" href="perlvms.html#time">#</a>time</dt>
<dd>

<p>The value returned by <code>time</code> is the offset in seconds from 01-JAN-1970 00:00:00 (just like the CRTL&#39;s times() routine), in order to make life easier for code coming in from the POSIX/Unix world.</p>

</dd>
<dt id="times"><a class="permalink" href="perlvms.html#times">#</a>times</dt>
<dd>

<p>The array returned by the <code>times</code> operator is divided up according to the same rules the CRTL <code>times()</code> routine. Therefore, the &quot;system time&quot; elements will always be 0, since there is no difference between &quot;user time&quot; and &quot;system&quot; time under VMS, and the time accumulated by a subprocess may or may not appear separately in the &quot;child time&quot; field, depending on whether <code>times()</code> keeps track of subprocesses separately. Note especially that the VAXCRTL (at least) keeps track only of subprocesses spawned using <code>fork()</code> and <code>exec()</code>; it will not accumulate the times of subprocesses spawned via pipes, <code>system()</code>, or backticks.</p>

</dd>
<dt id="unlink-LIST"><a class="permalink" href="perlvms.html#unlink-LIST">#</a><a id="unlink"></a>unlink LIST</dt>
<dd>

<p><code>unlink</code> will delete the highest version of a file only; in order to delete all versions, you need to say</p>

<pre><code>1 while unlink LIST;</code></pre>

<p>You may need to make this change to scripts written for a Unix system which expect that after a call to <code>unlink</code>, no files with the names passed to <code>unlink</code> will exist. (Note: This can be changed at compile time; if you <code>use Config</code> and <code>$Config{&#39;d_unlink_all_versions&#39;}</code> is <code>define</code>, then <code>unlink</code> will delete all versions of a file on the first call.)</p>

<p><code>unlink</code> will delete a file if at all possible, even if it requires changing file protection (though it won&#39;t try to change the protection of the parent directory). You can tell whether you&#39;ve got explicit delete access to a file by using the <code>VMS::Filespec::candelete</code> operator. For instance, in order to delete only files to which you have delete access, you could say something like</p>

<pre><code>sub safe_unlink {
    my($file,$num);
    foreach $file (@_) {
        next unless VMS::Filespec::candelete($file);
        $num += unlink $file;
    }
    $num;
}</code></pre>

<p>(or you could just use <code>VMS::Stdio::remove</code>, if you&#39;ve installed the VMS::Stdio extension distributed with Perl). If <code>unlink</code> has to change the file protection to delete the file, and you interrupt it in midstream, the file may be left intact, but with a changed ACL allowing you delete access.</p>

<p>This behavior of <code>unlink</code> is to be compatible with POSIX behavior and not traditional VMS behavior.</p>

</dd>
<dt id="utime-LIST"><a class="permalink" href="perlvms.html#utime-LIST">#</a><a id="utime"></a>utime LIST</dt>
<dd>

<p>This operator changes only the modification time of the file (VMS revision date) on ODS-2 volumes and ODS-5 volumes without access dates enabled. On ODS-5 volumes with access dates enabled, the true access time is modified.</p>

</dd>
<dt id="waitpid-PID,FLAGS"><a class="permalink" href="perlvms.html#waitpid-PID,FLAGS">#</a><a id="waitpid"></a><a id="waitpid-PID-FLAGS"></a>waitpid PID,FLAGS</dt>
<dd>

<p>If PID is a subprocess started by a piped <code>open()</code> (see <a href="open.html">open</a>), <code>waitpid</code> will wait for that subprocess, and return its final status value in <code>$?</code>. If PID is a subprocess created in some other way (e.g. SPAWNed before Perl was invoked), <code>waitpid</code> will simply check once per second whether the process has completed, and return when it has. (If PID specifies a process that isn&#39;t a subprocess of the current process, and you invoked Perl with the <code>-w</code> switch, a warning will be issued.)</p>

<p>Returns PID on success, -1 on error. The FLAGS argument is ignored in all cases.</p>

</dd>
</dl>

<h1 id="Perl-variables"><a class="permalink" href="perlvms.html#Perl-variables">#</a><a id="Perl2"></a>Perl variables</h1>

<p>The following VMS-specific information applies to the indicated &quot;special&quot; Perl variables, in addition to the general information in <a href="perlvar.html">perlvar</a>. Where there is a conflict, this information takes precedence.</p>

<dl>

<dt id="%ENV"><a class="permalink" href="perlvms.html#%25ENV">#</a><a id="ENV"></a>%ENV</dt>
<dd>

<p>The operation of the <code>%ENV</code> array depends on the translation of the logical name <i>PERL_ENV_TABLES</i>. If defined, it should be a search list, each element of which specifies a location for <code>%ENV</code> elements. If you tell Perl to read or set the element <code>$ENV{</code><i>name</i><code>}</code>, then Perl uses the translations of <i>PERL_ENV_TABLES</i> as follows:</p>

<dl>

<dt id="CRTL_ENV"><a class="permalink" href="perlvms.html#CRTL_ENV">#</a>CRTL_ENV</dt>
<dd>

<p>This string tells Perl to consult the CRTL&#39;s internal <code>environ</code> array of key-value pairs, using <i>name</i> as the key. In most cases, this contains only a few keys, but if Perl was invoked via the C <code>exec[lv]e()</code> function, as is the case for some embedded Perl applications or when running under a shell such as GNV bash, the <code>environ</code> array may have been populated by the calling program.</p>

</dd>
<dt id="CLISYM_[LOCAL]"><a class="permalink" href="perlvms.html#CLISYM_%5BLOCAL%5D">#</a><a id="CLISYM_"></a><a id="CLISYM_-LOCAL"></a>CLISYM_[LOCAL]</dt>
<dd>

<p>A string beginning with <code>CLISYM_</code>tells Perl to consult the CLI&#39;s symbol tables, using <i>name</i> as the name of the symbol. When reading an element of <code>%ENV</code>, the local symbol table is scanned first, followed by the global symbol table.. The characters following <code>CLISYM_</code> are significant when an element of <code>%ENV</code> is set or deleted: if the complete string is <code>CLISYM_LOCAL</code>, the change is made in the local symbol table; otherwise the global symbol table is changed.</p>

</dd>
<dt id="Any-other-string"><a class="permalink" href="perlvms.html#Any-other-string">#</a><a id="Any"></a>Any other string</dt>
<dd>

<p>If an element of <i>PERL_ENV_TABLES</i> translates to any other string, that string is used as the name of a logical name table, which is consulted using <i>name</i> as the logical name. The normal search order of access modes is used.</p>

</dd>
</dl>

<p><i>PERL_ENV_TABLES</i> is translated once when Perl starts up; any changes you make while Perl is running do not affect the behavior of <code>%ENV</code>. If <i>PERL_ENV_TABLES</i> is not defined, then Perl defaults to consulting first the logical name tables specified by <i>LNM$FILE_DEV</i>, and then the CRTL <code>environ</code> array. This default order is reversed when the logical name <i>GNV$UNIX_SHELL</i> is defined, such as when running under GNV bash.</p>

<p>For operations on %ENV entries based on logical names or DCL symbols, the key string is treated as if it were entirely uppercase, regardless of the case actually specified in the Perl expression. Entries in %ENV based on the CRTL&#39;s environ array preserve the case of the key string when stored, and lookups are case sensitive.</p>

<p>When an element of <code>%ENV</code> is read, the locations to which <i>PERL_ENV_TABLES</i> points are checked in order, and the value obtained from the first successful lookup is returned. If the name of the <code>%ENV</code> element contains a semi-colon, it and any characters after it are removed. These are ignored when the CRTL <code>environ</code> array or a CLI symbol table is consulted. However, the name is looked up in a logical name table, the suffix after the semi-colon is treated as the translation index to be used for the lookup. This lets you look up successive values for search list logical names. For instance, if you say</p>

<pre><code>$  Define STORY  once,upon,a,time,there,was
$  perl -e &quot;for ($i = 0; $i &lt;= 6; $i++) &quot; -
_$ -e &quot;{ print $ENV{&#39;story;&#39;.$i},&#39; &#39;}&quot;</code></pre>

<p>Perl will print <code>ONCE UPON A TIME THERE WAS</code>, assuming, of course, that <i>PERL_ENV_TABLES</i> is set up so that the logical name <code>story</code> is found, rather than a CLI symbol or CRTL <code>environ</code> element with the same name.</p>

<p>When an element of <code>%ENV</code> is set to a defined string, the corresponding definition is made in the location to which the first translation of <i>PERL_ENV_TABLES</i> points. If this causes a logical name to be created, it is defined in supervisor mode. (The same is done if an existing logical name was defined in executive or kernel mode; an existing user or supervisor mode logical name is reset to the new value.) If the value is an empty string, the logical name&#39;s translation is defined as a single <code>NUL</code> (ASCII <code>\0</code>) character, since a logical name cannot translate to a zero-length string. (This restriction does not apply to CLI symbols or CRTL <code>environ</code> values; they are set to the empty string.)</p>

<p>When an element of <code>%ENV</code> is set to <code>undef</code>, the element is looked up as if it were being read, and if it is found, it is deleted. (An item &quot;deleted&quot; from the CRTL <code>environ</code> array is set to the empty string.) Using <code>delete</code> to remove an element from <code>%ENV</code> has a similar effect, but after the element is deleted, another attempt is made to look up the element, so an inner-mode logical name or a name in another location will replace the logical name just deleted. In either case, only the first value found searching PERL_ENV_TABLES is altered. It is not possible at present to define a search list logical name via %ENV.</p>

<p>The element <code>$ENV{DEFAULT}</code> is special: when read, it returns Perl&#39;s current default device and directory, and when set, it resets them, regardless of the definition of <i>PERL_ENV_TABLES</i>. It cannot be cleared or deleted; attempts to do so are silently ignored.</p>

<p>Note that if you want to pass on any elements of the C-local environ array to a subprocess which isn&#39;t started by fork/exec, or isn&#39;t running a C program, you can &quot;promote&quot; them to logical names in the current process, which will then be inherited by all subprocesses, by saying</p>

<pre><code>foreach my $key (qw[C-local keys you want promoted]) {
    my $temp = $ENV{$key}; # read from C-local array
    $ENV{$key} = $temp;    # and define as logical name
}</code></pre>

<p>(You can&#39;t just say <code>$ENV{$key} = $ENV{$key}</code>, since the Perl optimizer is smart enough to elide the expression.)</p>

<p>Don&#39;t try to clear <code>%ENV</code> by saying <code>%ENV = ();</code>, it will throw a fatal error. This is equivalent to doing the following from DCL:</p>

<pre><code class="plaintext">DELETE/LOGICAL *</code></pre>

<p>You can imagine how bad things would be if, for example, the SYS$MANAGER or SYS$SYSTEM logical names were deleted.</p>

<p>At present, the first time you iterate over %ENV using <code>keys</code>, or <code>values</code>, you will incur a time penalty as all logical names are read, in order to fully populate %ENV. Subsequent iterations will not reread logical names, so they won&#39;t be as slow, but they also won&#39;t reflect any changes to logical name tables caused by other programs.</p>

<p>You do need to be careful with the logical names representing process-permanent files, such as <code>SYS$INPUT</code> and <code>SYS$OUTPUT</code>. The translations for these logical names are prepended with a two-byte binary value (0x1B 0x00) that needs to be stripped off if you want to use it. (In previous versions of Perl it wasn&#39;t possible to get the values of these logical names, as the null byte acted as an end-of-string marker)</p>

</dd>
<dt id="$!"><a class="permalink" href="perlvms.html#$!">#</a><a id="pod"></a>$!</dt>
<dd>

<p>The string value of <code>$!</code> is that returned by the CRTL&#39;s strerror() function, so it will include the VMS message for VMS-specific errors. The numeric value of <code>$!</code> is the value of <code>errno</code>, except if errno is EVMSERR, in which case <code>$!</code> contains the value of vaxc$errno. Setting <code>$!</code> always sets errno to the value specified. If this value is EVMSERR, it also sets vaxc$errno to 4 (NONAME-F-NOMSG), so that the string value of <code>$!</code> won&#39;t reflect the VMS error message from before <code>$!</code> was set.</p>

</dd>
<dt id="$^E"><a class="permalink" href="perlvms.html#$%5EE">#</a><a id="E"></a>$^E</dt>
<dd>

<p>This variable provides direct access to VMS status values in vaxc$errno, which are often more specific than the generic Unix-style error messages in <code>$!</code>. Its numeric value is the value of vaxc$errno, and its string value is the corresponding VMS message string, as retrieved by sys$getmsg(). Setting <code>$^E</code> sets vaxc$errno to the value specified.</p>

<p>While Perl attempts to keep the vaxc$errno value to be current, if errno is not EVMSERR, it may not be from the current operation.</p>

</dd>
<dt id="$?"><a class="permalink" href="perlvms.html#$?">#</a><a id="pod1"></a>$?</dt>
<dd>

<p>The &quot;status value&quot; returned in <code>$?</code> is synthesized from the actual exit status of the subprocess in a way that approximates POSIX wait(5) semantics, in order to allow Perl programs to portably test for successful completion of subprocesses. The low order 8 bits of <code>$?</code> are always 0 under VMS, since the termination status of a process may or may not have been generated by an exception.</p>

<p>The next 8 bits contain the termination status of the program.</p>

<p>If the child process follows the convention of C programs compiled with the _POSIX_EXIT macro set, the status value will contain the actual value of 0 to 255 returned by that program on a normal exit.</p>

<p>With the _POSIX_EXIT macro set, the Unix exit value of zero is represented as a VMS native status of 1, and the Unix values from 2 to 255 are encoded by the equation:</p>

<pre><code class="plaintext">VMS_status = 0x35a000 + (unix_value * 8) + 1.</code></pre>

<p>And in the special case of Unix value 1 the encoding is:</p>

<pre><code class="plaintext">VMS_status = 0x35a000 + 8 + 2 + 0x10000000.</code></pre>

<p>For other termination statuses, the severity portion of the subprocess&#39;s exit status is used: if the severity was success or informational, these bits are all 0; if the severity was warning, they contain a value of 1; if the severity was error or fatal error, they contain the actual severity bits, which turns out to be a value of 2 for error and 4 for severe_error. Fatal is another term for the severe_error status.</p>

<p>As a result, <code>$?</code> will always be zero if the subprocess&#39;s exit status indicated successful completion, and non-zero if a warning or error occurred or a program compliant with encoding _POSIX_EXIT values was run and set a status.</p>

<p>How can you tell the difference between a non-zero status that is the result of a VMS native error status or an encoded Unix status? You can not unless you look at the ${^CHILD_ERROR_NATIVE} value. The ${^CHILD_ERROR_NATIVE} value returns the actual VMS status value and check the severity bits. If the severity bits are equal to 1, then if the numeric value for <code>$?</code> is between 2 and 255 or 0, then <code>$?</code> accurately reflects a value passed back from a Unix application. If <code>$?</code> is 1, and the severity bits indicate a VMS error (2), then <code>$?</code> is from a Unix application exit value.</p>

<p>In practice, Perl scripts that call programs that return _POSIX_EXIT type status values will be expecting those values, and programs that call traditional VMS programs will either be expecting the previous behavior or just checking for a non-zero status.</p>

<p>And success is always the value 0 in all behaviors.</p>

<p>When the actual VMS termination status of the child is an error, internally the <code>$!</code> value will be set to the closest Unix errno value to that error so that Perl scripts that test for error messages will see the expected Unix style error message instead of a VMS message.</p>

<p>Conversely, when setting <code>$?</code> in an END block, an attempt is made to convert the POSIX value into a native status intelligible to the operating system upon exiting Perl. What this boils down to is that setting <code>$?</code> to zero results in the generic success value SS$_NORMAL, and setting <code>$?</code> to a non-zero value results in the generic failure status SS$_ABORT. See also <a href="perlport.html#exit">&quot;exit&quot; in perlport</a>.</p>

<p>With the <code>PERL_VMS_POSIX_EXIT</code> logical name defined as &quot;ENABLE&quot;, setting <code>$?</code> will cause the new value to be encoded into <code>$^E</code> so that either the original parent or child exit status values 0 to 255 can be automatically recovered by C programs expecting _POSIX_EXIT behavior. If both a parent and a child exit value are non-zero, then it will be assumed that this is actually a VMS native status value to be passed through. The special value of 0xFFFF is almost a NOOP as it will cause the current native VMS status in the C library to become the current native Perl VMS status, and is handled this way as it is known to not be a valid native VMS status value. It is recommend that only values in the range of normal Unix parent or child status numbers, 0 to 255 are used.</p>

<p>The pragma <code>use vmsish &#39;status&#39;</code> makes <code>$?</code> reflect the actual VMS exit status instead of the default emulation of POSIX status described above. This pragma also disables the conversion of non-zero values to SS$_ABORT when setting <code>$?</code> in an END block (but zero will still be converted to SS$_NORMAL).</p>

<p>Do not use the pragma <code>use vmsish &#39;status&#39;</code> with <code>PERL_VMS_POSIX_EXIT</code> enabled, as they are at times requesting conflicting actions and the consequence of ignoring this advice will be undefined to allow future improvements in the POSIX exit handling.</p>

<p>In general, with <code>PERL_VMS_POSIX_EXIT</code> enabled, more detailed information will be available in the exit status for DCL scripts or other native VMS tools, and will give the expected information for Posix programs. It has not been made the default in order to preserve backward compatibility.</p>

<p>N.B. Setting <code>DECC$FILENAME_UNIX_REPORT</code> implicitly enables <code>PERL_VMS_POSIX_EXIT</code>.</p>

</dd>
<dt id="$|"><a class="permalink" href="perlvms.html#$%7C">#</a><a id="pod2"></a>$|</dt>
<dd>

<p>Setting <code>$|</code> for an I/O stream causes data to be flushed all the way to disk on each write (<i>i.e.</i> not just to the underlying RMS buffers for a file). In other words, it&#39;s equivalent to calling fflush() and fsync() from C.</p>

</dd>
</dl>

<h1 id="Standard-modules-with-VMS-specific-differences"><a class="permalink" href="perlvms.html#Standard-modules-with-VMS-specific-differences">#</a><a id="Standard"></a>Standard modules with VMS-specific differences</h1>

<h2 id="SDBM_File"><a class="permalink" href="perlvms.html#SDBM_File">#</a>SDBM_File</h2>

<p>SDBM_File works properly on VMS. It has, however, one minor difference. The database directory file created has a <i>.sdbm_dir</i> extension rather than a <i>.dir</i> extension. <i>.dir</i> files are VMS filesystem directory files, and using them for other purposes could cause unacceptable problems.</p>

<h1 id="Revision-date"><a class="permalink" href="perlvms.html#Revision-date">#</a><a id="Revision"></a>Revision date</h1>

<p>Please see the git repository for revision history.</p>

<h1 id="AUTHOR"><a class="permalink" href="perlvms.html#AUTHOR">#</a>AUTHOR</h1>

<p>Charles Bailey bailey@cor.newman.upenn.edu Craig Berry craigberry@mac.com Dan Sugalski dan@sidhe.org John Malmberg wb8tyw@qsl.net</p>


      </div>
      <div id="footer">
        <p>Perldoc Browser is maintained by Dan Book (<a href="https://metacpan.org/author/DBOOK">DBOOK</a>). Please contact him via the <a href="https://github.com/Grinnz/perldoc-browser/issues">GitHub issue tracker</a> or <a href="mailto:dbook@cpan.org">email</a> regarding any issues with the site itself, search, or rendering of documentation.</p>

<p>The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the <a href="https://github.com/Perl/perl5/issues">Perl issue tracker</a>, the <a href="https://lists.perl.org/list/perl5-porters.html">mailing list</a>, or <a href="https://kiwiirc.com/client/irc.perl.org/p5p">IRC</a> to report any issues with the contents or format of the documentation.</p>


      </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
    <script src="../highlight.pack.js"></script>
    <script>hljs.highlightAll();</script>
  </body>
</html>
